/*
 * Copyright (c) 2009. Silenus Consultoria, S.L.
 */
package es.silenus.detecta.dao.impl;

import es.silenus.detecta.dao.SurveyAnswerHeaderImportedDAO;

import es.silenus.detecta.model.SurveyAnswerHeaderImported;

import org.hibernate.FetchMode;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import java.util.Map;


/**
 * DOCUMENT ME!
 *
 * @author <a href="mailto:dgarcia@silenus-consultoria.es">Daniel Garc&iacute;a</a>
 *
 * @since 02-abr-2009 12:44:50
 */
public class SurveyAnswerHeaderImportedDAOImpl extends ReadWriteDAOImpl<SurveyAnswerHeaderImported, Long>
	implements SurveyAnswerHeaderImportedDAO {
	/**
	 * Override this method to provide a find by example page criteria.
	 *
	 * @param criteria the criteria.
	 * @param object the sample object.
	 *
	 * @return the criteria.
	 */
	protected DetachedCriteria preparePageCriteria(final DetachedCriteria criteria, final Map<String, Object> object) {
		criteria.setFetchMode("importedFile", FetchMode.JOIN);

		Object temp = object.get("idFile");

		if(temp != null) {
			criteria.add(Restrictions.eq("importedFile.id", temp));
		}

		return criteria;
	}

	/**
	 * Override this method to provide a find by example list criteria.
	 *
	 * @param criteria the criteria.
	 * @param object the sample object.
	 *
	 * @return the criteria.
	 */
	protected DetachedCriteria prepareListCriteria(final DetachedCriteria criteria, final Map<String, Object> object) {
		return preparePageCriteria(criteria, object);
	}
}
